package cn.lcsjsxy.yxz.day.Set;

import java.util.LinkedList;

//Linkedlist基本操作
public class LinkedlistBasicoperations {

    public static void main(String[] args) {

        //构建集合对象
        LinkedList list = new LinkedList();

        //增加一个数据
        list.add("123");
        list.addFirst("789");
        list.add(1,"456");

        //获取信息
        System.out.println(list.getFirst());
        System.out.println(list.getLast());

        //获取数据
        System.out.println(list.get(1));

        for (int i = 0; i < list.size(); i++){
            System.out.println(list.get(i));
        }
        for (Object obj : list){
            System.out.println(obj);
        }

        //修改数据
        list.set(1,"147");
        //删除
        list.remove("258");

        //输出
        System.out.println(list);
    }

}
